/*
This file is part of buco.  
Copyright (c) 2012 Christopher Pawelzik <christopher@cpawelzik.com>

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php 
*/ 

package buco.core.internal;

import java.util.*;

public class HeaderElement {
	private String name; 
	private ArrayList<Attribute> attributes;
	private HashMap<String, Attribute> hashtable; 
	
	public HeaderElement(String name) {
		attributes = new ArrayList<Attribute>();
		hashtable = new HashMap<String, Attribute>(); 
		this.name = name;   
	}
	
	public void addAttribute(Attribute attribute) {
		attributes.add(attribute); 		
		hashtable.put(attribute.getKey(), attribute); 
	}
	
	public String getName() { 
		return this.name; 
	}
	
	public List<Attribute> getAttributes() { 
		return attributes; 
	}
	
	public int getAttributeCount() {
		return attributes.size(); 
	}
	
	public Attribute getAttributeFromKey(String key) {
		if(!hashtable.containsKey(key))
			return null; 
		
		return hashtable.get(key); 
	}
}
